﻿using System;
using System.Web.UI;
using PAS.Helper;

namespace PAS
{
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                DataConnHelper.IsLogin = false;
        }

        protected void btnSelectOption_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Length == 0)
            {
                Alert.MessageBox("请先输入" + PeopleInfo.MemoName);
                return;
            }
            var hlp = new DataConnHelper();
            var peopleInfo = hlp.CheckPeopleLogin(txtName.Text);
            if (peopleInfo != null && peopleInfo.Length==3)
            {
                Response.Redirect("SelectOptionForm.aspx?Id=" + Server.UrlPathEncode(peopleInfo[0]
                    +"&Name="+peopleInfo[1]+"&GroupName="+peopleInfo[2]));
            }
            else
                Alert.MessageBox("参与者不存在,请与系统管理员联系!");
            
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtPwd.Text.Length == 0)
            {
                Alert.MessageBox("请先输入管理员密码");
                return;
            }

            var hlp = new DataConnHelper();
            bool isPass = hlp.CheckSysAdminLogin(txtPwd.Text);
            DataConnHelper.IsLogin = isPass;
            if (isPass)
            {
                Response.Redirect("SysMain.aspx");
            }
            else
                Alert.MessageBox("系统管理员密码不正确");
        }
    }
}